package com.lb.uts.service;

import com.github.pagehelper.PageInfo;
import com.lb.uts.entity.ScheduleJob;
import com.lb.uts.exception.UTSException;
import com.lb.uts.mapper.ScheduleJobMapper;
import com.lb.uts.entity.JobSearch;
import org.quartz.SchedulerException;

import java.util.List;

/**
 * @author liangb
 * @date 2019/4/26 17:17
 */
public interface IScheduleJobService extends IBaseService<ScheduleJobMapper, ScheduleJob> {


    /**
     * @return 未删除的定时任务列表
     */
    List<ScheduleJob> selectUnDeleteList();

    /**
     * 根据jobName进行查询
     *
     * @param jobName
     */
    int selectUniqe(String jobName, String jobGroup);

    ScheduleJob selectUniqeJob(String jobName, String jobGroup);

    int updateRedRunNum(String jobId, String possession, Integer concurrentNum);

    /**
     * 不做数量限制的时候，做累加操作
     */
    int updateRunNum(String jobId, String possession, Integer concurrentNum, int num);

    int updateIncRunNum(String jobId, String possession, Integer concurrentNum);

    int updateStatus(ScheduleJob scheduleJob);

    PageInfo<ScheduleJob> queryList(JobSearch jobSearch, int pageNo, int pageSize);

    void executeJob(String jobId) throws Exception;

    Integer saveJobInfo(ScheduleJob scheduleJob, Integer concurrentCount) throws SchedulerException;

    void resumeJob(String jobId) throws SchedulerException;

    void deleteJob(String jobId) throws SchedulerException;

    void updateJob(ScheduleJob scheduleJob, Integer concurrentCount) throws UTSException, SchedulerException;

    void pauseJob(String jobId) throws SchedulerException;

    /**
     * 更新possession为null
     * @param jobId
     * @return
     */
    int updatePossession(String jobId);
}
